/*	Start jQuery	*/
jQuery(document).ready(function () {

    /* Floating header  (using width jquery only)
    --------------------------------------------------------------------- */

    var showHeight = $('#wrapper-content').offset();
    var floatLogo = $('#logo a');
    var floatNav = $('#main-nav ul');

    // Build Floated header
    $("<div id='floated-header'>\
                <div class='center-element'>\
                    <div id='floated-logo'>" + floatLogo.html() + "</div>\
                    <ul id='floated-nav'>" + floatNav.html() + "<li id='scrollTop'><a href='#'>Top</a></li></ul>\
                </div>\
               </div>").appendTo("body");

    $("#floated-header #floated-nav li").css({ background: "none" });

    // Check on page load
    if ($(window).scrollTop() > (showHeight.top)) {
        $('#floated-header').fadeIn();
    }

    // Check on scroll event
    jQuery(window).scroll(function () {
        if ($(window).scrollTop() > (showHeight.top + 40)) {
            $('#floated-header').fadeIn();
        } else {
            $('#floated-header').fadeOut();
        }
    });

    // Scroll top link
    var scrollTop = $("#scrollTop a").css({ opacity: .3 });

    scrollTop.hover(function () {
        scrollTop.stop(true, true).animate({ opacity: 1 });
    }, function () {
        scrollTop.stop(true, true).animate({ opacity: .3 });
    });

    scrollTop.click(function () {
        $("html,body").animate({ scrollTop: 0 }, 2000, "easeOutQuint", function () {
            $('#floated-header').fadeOut();
        });
        return false;
    });
    /* END Floating header
    --------------------------------------------------------------------- */
});
/* jQuery END  */